package com.study.web;

import com.alibaba.fastjson.JSON;
import com.study.config.IdWorks;
import com.study.dao.DeptMapper;
import com.study.dao.LoggerMapper;
import com.study.entity.Dept;
import com.study.entity.Logger;
import com.study.service.DeptService;
import com.study.service.LoggerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * 部门
 *
 * @author : 89007337.zhuyanpeng
 * @date :Create in  2019/8/23- 19:16
 **/
@RestController
@RequestMapping("/dept")
public class DeptController {

    @Autowired
    DeptService deptService;
    @Autowired
    LoggerService loggerService;

    @GetMapping("")
    public String get(){
        List<Dept> depts = deptService.queryList();
        return JSON.toJSONString(depts);
    }

    @PostMapping("")
    public String post(@RequestBody Dept dept){
        dept.setId(IdWorks.getId());
        dept.setCreateTime(new Date());
        deptService.save(dept);
        return "OK";
    }

}
